<?php
/**
 * Created by PhpStorm.
 * User: ZT
 * Date: 2020/7/6 0006
 * Time: 10:19
 **/
namespace backend\controllers;


use backend\component\BackendBaseController;
use common\models\info\Mood;
use backend\component\ResultFormat;
use common\utils\CommonUtil;
use frontend\service\MoodService;
use yii\helpers\ArrayHelper;

class MoodController extends BackendBaseController
{
    public function actions()
    {
        return ArrayHelper::merge(parent::actions(),[
            "modify" => [
                'class' => "backend\actions\ModifyAction",
                'modelName' => Mood::className()
            ],
            "delete" => [
                'class' => "backend\actions\DeleteAction",
                'modelName' => Mood::className(),
                'is_physics' => true
            ],
            "switch" => [
                "class" => "backend\actions\SwitchAction",
                "modelName" => Mood::className(),
                "field" => "status",
            ],
        ]);
    }
    public function actionList() {
        $data= MoodService::moodList(\Yii::$app->request->get());
        return ResultFormat::success('SUCCESS',json_decode($data));
    }
    public function actionVerifyload(){
        $post = \Yii::$app->request->post("form");
        $id =$post['id'];
        return MoodService::auditMood($id,$post);
    }
    public function actionStatus(){
        $model = new Mood();
        $list = $model::$statusDropdownList;
        return ResultFormat::success('SUCCESS',$list);
    }
    /**
     * 编辑
     * @return mixed
     */
    public function actionEdit() {
        $id = \Yii::$app->request->get("id",0);
        $model = Mood::modelById($id);
        $data = $model->attributes;
        return ResultFormat::success('SUCCESS',$data);
    }

}